from flask_restful import Api as _Api
from werkzeug.exceptions import HTTPException
from app import app


class Api(_Api):
    def error_router(self, original_handler, e):
        """ Override original error_router to only handle HTTPExceptions. """
        if self._has_fr_route() and isinstance(e, HTTPException):
            try:
                return self.handle_error(e)
            except Exception:
                pass  # Fall through to original handler
        return original_handler(e)


api = Api(app)

